﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OBNEPGGrabber
{
    static class CodeFinder
    {
        static IStatusUpdate m_IUpdate;

        public static string FindCode(DirectoryInfo dirInfo, string strFileName, IStatusUpdate IUpdate)
        {
            // Register status update interface
            m_IUpdate = IUpdate;
            return ReadFile(dirInfo.FullName + "\\" + strFileName);
        }

        private static string ReadFile(string strFileName)
        {
            // Read an HTML file to find the name of the file containing channel info
            string text = System.IO.File.ReadAllText(strFileName);
            int idx = text.IndexOf("src=");
            int idx2 = text.IndexOf(">", idx);
            string strURL = text.Substring(idx+5, idx2-1-(idx+5));
            return strURL;
        }
    }
}
